/**
 * 
 */
package mdb.com.vn.persist;

import java.io.Serializable;
import java.util.List;

import mdb.com.vn.model.ScratchCard;

import org.springframework.stereotype.Repository;

/**
 * @author tu.dod
 *
 */
@Repository("scratchCardDAO")
public class ScratchCardDAOImpl extends AbstractHibernateDAOImpl<ScratchCard, Integer>  implements ScratchCardDAO,Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@SuppressWarnings("unchecked")
	@Override
	public List<ScratchCard> findByRef(String transRef) {
		// TODO Auto-generated method stub
		return getSession().getNamedQuery("ScratchCard.findByRef").setString("transRef", transRef).list();
	}

	@Override
	protected Class<ScratchCard> getDomainClass() {
		// TODO Auto-generated method stub
		return ScratchCard.class;
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<ScratchCard> findByRef1(String transRef1) {
		// TODO Auto-generated method stub
		return getSession().getNamedQuery("ScratchCard.findByRef1").setString("transRef1", transRef1).list();
	}

	@SuppressWarnings("unchecked")
	@Override
	public int countByDenomination(double scDenomination) {
		// TODO Auto-generated method stub
		List<Long> list =  getSession().getNamedQuery("ScratchCard.countByDeno").setDouble("scDenomination", scDenomination).list();
		if (list != null){
			return list.get(0).intValue();
		}
		return 0;
	}

}
